package cycling.taxi.com.person;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import butterknife.ButterKnife;
import butterknife.InjectView;
import cn.jpush.android.api.JPushInterface;
import cycling.taxi.com.R;
import cycling.taxi.com.ui.activity.ChangePasswordActivity;
import cycling.taxi.com.ui.activity.ForgetPasswordActivity;
import cycling.taxi.com.utils.SPUtil;
import cycling.taxi.com.utils.ToastUtil;

/**
 * 设置界面，打开消息推送，清理缓存，修改密码等
 */
public class SettingActivity extends AppCompatActivity implements View.OnClickListener{
    @InjectView(R.id.back)
    ImageView back;
//    @InjectView(R.id.check)
//    CheckBox mCheck;
//    @InjectView(R.id.rl_state_jphsh)
//    RelativeLayout mRlStateJphsh;
    @InjectView(R.id.rl_chance_gesture)
    RelativeLayout mRlChanceGesture;
//    @InjectView(R.id.rl_chance_phone)
//    RelativeLayout mRlChancePhone;
    @InjectView(R.id.exit_app)
    Button exit;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_setting);
        ExitApplication.getInstance().addActivity(this);
        ButterKnife.inject(this);
        setListenr();
    }
    private void setListenr() {
        back.setOnClickListener(this);
        exit.setOnClickListener(this);
        mRlChanceGesture.setOnClickListener(this);

//        //设置极光的开关
//        mCheck.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
//            @Override
//            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
//                ToastUtil.getInstance().toast(isChecked+"");
//                if (isChecked){
//                    //开启极光
//                    JPushInterface.resumePush(getApplicationContext());
//                }else {
//                    //关闭极光
//                    JPushInterface.stopPush(getApplicationContext());
//                }
//            }
//        });
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.back:
                //关闭界面
                finish();
                break;
            case R.id.rl_chance_gesture:
                //修改密码
                startToAty(ForgetPasswordActivity.class);
                break;
//            case R.id.rl_chance_phone:
//                //更改手机号
//                break;
            case R.id.exit_app:
                SPUtil.getInstance().setData("beanJson",null);
                SPUtil.getInstance().setData("password",null);
                ExitApplication.getInstance().exit();
                ExitApplication.getInstance().addActivity(this);
                break;
        }

    }

    private void startToAty(Class claz) {
        Intent intent = new Intent(this, claz);
        startActivity(intent);
    }
}
